package com.eastfair.projectcore.api;

import com.eastfair.core.base.R;
import com.eastfair.projectcore.dto.ConfigAttributeDTO;
import com.eastfair.projectcore.dto.FunctionDTO;
import com.eastfair.projectcore.dto.MenuDTO;
import com.eastfair.projectcore.dto.MsgTemplatePageQuery;
import com.eastfair.projectcore.entity.Area;
import com.eastfair.projectcore.entity.Exhibition;
import com.eastfair.projectcore.entity.MsgTemplate;
import com.eastfair.projectcore.entity.ProjectDb;
import com.eastfair.projectcore.vo.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * feign接口
 *
 * @Author ligang
 * @Date 2020/3/16 16:41
 */
@FeignClient(value = "project-core")
public interface ProjectCoreServiceFeign {

    /**
     * 生成雪花id
     *
     * @return
     */
    @GetMapping("/projectDb/getSelfUid")
    Long getSelfUid(@RequestParam(value = "projectId") Long projectId);

    /**
     * 批量获取雪花ID
     *
     * @param projectId 项目id
     * @param count     数量
     * @return
     */
    @GetMapping("/projectDb/batGetSelfUid")
    List<Long> batGetSelfUid(@RequestParam(value = "projectId") Long projectId, @RequestParam(value = "count") Integer count);


    /**
     * 查询项目接口
     *
     * @return
     */
    @GetMapping("/projectDb/getById")
    R<ProjectDb> getProjectById(@RequestParam(value = "projectId") Long projectId);


    /**
     * 字典查询
     *
     * @return
     */
    @PostMapping("/dict/findByNames")
    Map<Serializable, Object> findByNames(@RequestBody Set<Serializable> types);

    /**
     * 老项目展会id换取新展会信息
     *
     * @return
     */
    @GetMapping("/exhibition/getExhibitionIdOfNew")
    Exhibition getExhibitionIdOfNew(@RequestParam(value = "oldId") String oldId);

    /**
     * 通过id获取展会
     *
     * @param id 展会id
     * @return
     */
    @ApiOperation(value = "通过id获取展会", notes = "通过id获取展会")
    @GetMapping("/exhibition/find/{id}")
    R<Exhibition> getExhibitionById(@PathVariable("id") Long id);


    /**
     * 通过子菜单查询菜单信息和全部子信息
     *
     * @return
     */
    @PostMapping("/menu/findAllByChildId")
    R<List<MenuVO>> findAllByChildId(@RequestBody MenuDTO menuDTO);

    /**
     * 查询菜单的权限标识
     *
     * @param menuDTO 菜单实体
     * @return 查询结果
     */
    @ApiOperation(value = "查询菜单的权限标识", notes = "查询菜单的权限标识")
    @PostMapping("/menu/findPermissionAllByChildId")
    R<List<String>> findPermissionAllByChildId(@RequestBody MenuDTO menuDTO);


    /**
     * 查询事件信息
     *
     * @return
     */
    @PostMapping("/function/findAll")
    R<List<FunctionVO>> findFunctionAll(@RequestBody FunctionDTO functionDTO);

    /**
     * 获取模板
     *
     * @param query projectId、type、tempType
     * @return 模版实体
     */
    @PostMapping("/msgTemplate/getTemp")
    MsgTemplate getMsgTemp(@RequestBody MsgTemplatePageQuery query);

    /**
     * 查询实体属性列表
     *
     * @param configAttributeDTO EntityClass
     * @return 实体属性列表
     */
    @PostMapping("/configAttribute/listByEntityClass")
    R<List<ConfigAttributeVO>> listByEntityClass(@RequestBody ConfigAttributeDTO configAttributeDTO);

    /**
     * 查询电子橱窗信息
     *
     * @return
     */
    @GetMapping("/hotImage/findAllById")
    List<HotImageVO> findAllById(@RequestParam(value = "exhibitionId") Long exhibitionId);


    /**
     * 推荐橱窗
     *
     * @return
     */
    @GetMapping("/hotImage/recommendHotImage")
    R recommendHotImage(@RequestParam(value = "id") Long id, @RequestParam(value = "isRecommend") Boolean isRecommend);


    /**
     * 置顶橱窗
     *
     * @return
     */
    @GetMapping("/hotImage/top")
    R top(@RequestParam(value = "id") Long id);

    /**
     * 通过id获取地区
     *
     * @param id 地区id
     * @return 地区实体
     */
    @ApiOperation(value = "通过id获取地区", notes = "通过id获取地区")
    @GetMapping("/area/find/{id}")
    R<Area> getAreaById(@PathVariable("id") Integer id);

    /**
     * 查询某地区电话区号
     *
     * @param id 地区id
     * @return 地区区号
     */
    @ApiOperation(value = "查询某地区电话区号", notes = "查询某地区电话区号")
    @GetMapping("/getPhoneCodeByAreaId/{id}")
    R<String> getPhoneCodeByAreaId(@PathVariable("id") Integer id);


    /**
     * 校对验证码
     *
     * @param verifyId
     * @param verifyValue
     * @return
     */
    @GetMapping("/kaptcha/imgvrify")
    R<Boolean> imgvrify(@RequestParam(value = "verifyId") String verifyId, @RequestParam(value = "verifyValue") String verifyValue);


    /**
     * 查询地区list
     *
     * @param area 区域级别
     * @return 地区列表
     */
    @ApiOperation(value = "查询地区list", notes = "查询地区list")
    @PostMapping("/area/queryListArea")
    R<List<AreaVO>> queryListArea(@RequestBody Area area);


    /**
     * 创建worknode
     *
     * @return
     */
    @ApiOperation(value = "创建worknode", notes = "创建worknode")
    @PostMapping("/workerNode/createWorkNode")
    Long createWorkNode();


}
